package com.zzyd.factory;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/7/18 10:24
 * @类注释:
 */
public class Factory {
    private static final Factory instance;
    private final Executor executor;
    private final Gson gson;
    private static boolean isShowLog = true;

    static {
        instance = new Factory();
    }

    private Factory() {
        executor = Executors.newFixedThreadPool(4);
        gson = new GsonBuilder()
                .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
//TODO                .setExclusionStrategies()
                .create();
    }

//    public static AppLication app() {
//        return AppLication.getInstance();
//    }

    /**
     * 异步
     *
     * @param runnable
     */
    public static void runOnAsync(Runnable runnable) {
        instance.executor.execute(runnable);
    }

    public static Gson getGson() {
        return instance.gson;
    }

    public static void LogE(String TAG, String msg) {
        if (isShowLog) {
            Log.e(TAG, msg);
        }
    }
}
